import React from "react"
import {RouteConfig} from "react-router-config";
import About from "@/pages/About";
import LayoutLoading from "@/components/layout/LayoutLoading";

const Doc = React.lazy(() => import("@/pages/doc"))
const Login = React.lazy(() => import("@/pages/login"))
const Home = React.lazy(() => import("@/pages/Home"))
const Log = React.lazy(() => import("@/pages/log/Log"))

export function createLayoutRoutes() {
  const routes: RouteConfig[] = [
    {
      name: "登录",
      path: `/login`,
      exact: true,
      component: (props: any) => (
        <React.Suspense fallback={<LayoutLoading/>}>
          <Login {...props} />
        </React.Suspense>
      ),
    }
  ];
  return routes;
}

export function createRoutes() {
  const routes: RouteConfig[] = [
    {
      path: `/doc`,
      component: (props: any) => (
        <React.Suspense fallback={<div/>}>
          <Doc {...props} />
        </React.Suspense>
      ),
    },
    {
      path: `/home`,
      component: (props: any) => (
        <React.Suspense fallback={<div/>}>
          <Home {...props} />
        </React.Suspense>
      ),
    },
    {
      path: `/about`,
      component: (props: any) => (
        <React.Suspense fallback={<div/>}>
          <About {...props} />
        </React.Suspense>
      ),
    },
    {
      path: `/log`,
      component: (props: any) => (
        <React.Suspense fallback={<div/>}>
          <Log {...props} />
        </React.Suspense>
      ),
    }
  ]
  return routes
}
